<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
	<meta charset="utf-8">
	<title>服务单创建 -CRM1.0</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="resources/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="resources/css/public.css" media="all" />
</head>
<body class="childrenBody">
<form class="layui-form layui-row layui-col-space7" id="dataFrm">
	<div class="layui-col-md1 ">&nbsp;</div>
	<div class="layui-col-md9 layui-col-xs7">
		<div class="layui-row layui-col-space10">
			<blockquote class="layui-elem-quote title magt10"><i class="layui-icon">&#xe609;</i> 创建</blockquote>
			<div class="border">
				<div class="layui-form-item">
					<label class="layui-form-label"><i class="layui-icon">&#xe60e;</i>类  型</label>
					<div class="layui-input-block servType">
						<select id="servType" name="servType" lay-verify="required">
							<option value="3">咨询</option>
							<option value="1">投诉</option>
							<option value="2">建议</option>
						</select>
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label"><i class="layui-icon">&#xe60e;</i>客 户</label>
					<div class="layui-input-block serv_cust_name">
						<select id="servCustNo" name="servCustNo" class="" lay-verify="servCustName">
						</select>
					</div>
				</div>


				<div class="layui-form-item">
					<label class="layui-form-label"><i class="layui-icon">&#xe609;</i> 创建人</label>
					<div class="layui-input-block">
						<input type="" id="reanNames" style="border: none;margin: 10px;color: #FF5722"  th:value="${session.USER_SESSION.realname}" readonly></input>
					</div>
				</div>


				<hr class="layui-bg-gray" />
				<div class="layui-right">
					<a class="layui-btn layui-btn-sm" lay-filter="newOrder" lay-submit><i class="layui-icon">&#xe609;</i>创建</a>
				</div>
			</div>
			<hr>
		</div>
		<div class="layui-row layui-col-space10">
				<div class="layui-form-item magt3">
					<label class="layui-form-label">服务单标题</label>
					<div class="layui-input-block">
						<input type="text" id="servTitle" name="servTitle" class="layui-input newsName" lay-verify="servTitle" placeholder="请输入服务单标题">
					</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label" >服务单内容</label>
					<div class="layui-input-block">
						<textarea placeholder="请输入内容" id="servRequest" name="servRequest" class="layui-textarea abstract" lay-verify="content"></textarea>
					</div>
				</div>
			</div>
		</div>
	</div>

</form>
<script type="text/javascript" src="resources/layui/layui.js"></script>

<script >
    layui.use(['form','layer','layedit','laydate','upload'],function(){
        var form = layui.form
        layer = parent.layer === undefined ? layui.layer : top.layer,
            laypage = layui.laypage,
            upload = layui.upload,
            layedit = layui.layedit,
            laydate = layui.laydate,
            $ = layui.jquery;



        //请求获取数据
        //动态绑定下拉菜单的数据
        var html;
        $.ajax({
            url:'/customer',
            success:function (data) {
                html += "<option value=''>------------请选择------------</option>"
                for (i = 0; i < data.length; i++) {
                    html += ("<option value='" + data[i].custNo + "'>" + data[i].custName + "</option>")
                }
                $("#servCustNo").append(html);
                form.render('select');
            }
        });

        //格式化时间
        function filterTime(val){
            if(val < 10){
                return "0" + val;
            }else{
                return val;
            }
        }





        form.verify({
            servTitle : function(val){
                if(val == ''){
                    return "标题不能为空";
                }
            },
            servRequest : function(val){
                if(val == ''){
                    return "内容不能为空";
                }
            }
        })
        form.on("submit(newOrder)",function(data){
            //截取文章内容中的一部分文字放入文章摘要
            var params=$("#dataFrm").serialize();
            var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
            //实际使用时的提交数据
            var params=$("#dataFrm").serialize();
            console.log(params);
            $.post("service.do",params,function (res) {
                console.log(res.code);
                if(res.code==1400){
                    top.layer.close(index);
                    top.layer.msg(res.msg);
                    setTimeout(function(){
                        var index1=parent.layer.getFrameIndex(window.name)
                        parent.layer.close(index1);
                        parent.location.reload();
                    },1000);

                }else if(res.code=-1400){
                    layer.msg(res.msg);
                }
            },"json");
            return false;

        });


    })
</script>
</body>
</html>